import request from '../flow-request'
import { ResponseData } from '@/types/api/public'
import { TableList,EditData } from '@/types/api/flowModel'
import { AxiosResponse } from 'axios'


type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

export const getData =(params:any):ConfigType<TableList> =>{
    params.PageNo=params.current;
    params.PageSize=params.pageSize;
    const data= JSON.stringify(params);
    return request({
        url:'/Api/v1/process-definitions/meta/list',
        method:'post',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const addData = (data: any): ConfigType => {
    return request({
      url: '/Api/v1/process-definitions/meta/save-model',
      method: 'post',
      data
    })
  }

  export const deployBpmnXml = (data: any): ConfigType => {
    return request({
      url: '/Api/v1/workflow/process-deployer',
      method: 'post',
      data
    })
  }

  export const saveBpmnXml = (data: any): ConfigType => {
    return request({
      url: '/Api/v1/process-definitions/meta/save-BpmnXml',
      method: 'post',
      data
    })
  }

  export const editGetData = (params: any): ConfigType<EditData> => {
    return request({
      url: '/Api/v1/process-definitions/meta/get-model',
      method: 'get',
      params
    })
  } 

  export const editData = (data: any): ConfigType => {
    return request({
      url: '/Api/v1/process-definitions/meta/save-model',
      method: 'post',
      data
    })
  }

  export const newModel = (): ConfigType => {
    return request({
      url: '/Api/v1/process-definitions/meta/new-model',
      method: 'get'
    })
  }

